![]() |
PATH![]() |
![]() ![]() |
You can use the global variable AppleScript to get properties of AppleScript itself rather than properties of the current target. You can refer to this global variable from any part of any script. AppleScript provides the following global properties you can use as constants: pi , return , space , tab , and version . These values are described in Arithmetic Constants, String Constants, and Version Constant. You should not attempt to change the values for these constants.
The Text Item Delimiters property consists of a list of strings used as delimiters by AppleScript when it coerces lists to strings or gets text items from strings. AppleScript currently uses only the first delimiter in the list.
You can get and set the current value of AppleScript's Text Item Delimiters. Normally, AppleScript doesn't use any delimiters. For example, if AppleScript's text delimiters have not been explicitly changed. the script
{"bread", "milk", "butter", 10.45} as string
"breadmilkbutter10.45"
For printing or display purposes, it is usually preferable to set the text delimiters to something that's easier to read. For example, the script
set AppleScript's text item delimiters to {", "}
{"bread", "milk", "butter", 10.45} as string
"bread, milk, butter, 10.45"
The Text Item Delimiters property also allows you to extract individual names from a pathname. For example, the script
set AppleScript's text item delimiters to {":"}
get last text item of "Hard Disk:CD Contents:Release Notes"
returns the result "Release Notes" .
If you change the Text Items Delimiters property in the Script Editor, it remains changed until you restore its previous value or until you quit the Script Editor and launch it again. If you change the Text Items Delimiters in a script application, it remains changed in that application until you restore its previous value or until the script application quits; however, the delimiters are not changed in the Script Editor or in other script applications you run.
You may want to use an error handler to reset the Text Item Delimiters property to its former value if an error occurs. For more information on handling errors, see Try Statements.
set savedTextItemDelimiters to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {"**"}
--other script statements...
--finally, reset the text item delimiters:
set AppleScript's text item delimiters to savedTextItemDelimiters
on error m number n from f to t partial result p
--also reset text item delimiters in case of an error:
set AppleScript's text item delimiters to savedTextItemDelimiters
--and resignal the error:
error m number n from f to t partial result p
end try